package _Pan3D.display3D
{
	import _Pan3D.base.MeshData;
	
	import component.Timeline;
	
	import flash.display3D.Context3D;
	import flash.display3D.textures.Texture;
	
	public class Display3DMovieLocal extends Display3DMovie
	{
		private var _pause:Boolean;
		public function Display3DMovieLocal(context:Context3D)
		{
			super(context);
		}
		public function addAnimLocal(name:String,ary:Array):void{
			_animDic[name] = ary;
			_curentAction = name;
			_curentFrame = 0;
		}
		public function addTextureLocal(place:String,texture:Texture):void{
			_textureDic[place] = texture;
		}
		public function addMeshLocal(place:String,meshData:MeshData):void{
			meshData.texture = _textureDic[place];
			_meshDic[place] = meshData;
		}
		public function removeMeshLocal(place:String):Object{
			delete _meshDic[place];
			return _meshDic;
		}
		override public function setFrame():void{
			if(pause){
				
			}else{
				super.setFrame();
			}
			Timeline.getInstance().setFrame(_curentFrame);
		}
		public function nextFrame():void{
			if(_curentAction && _animDic.hasOwnProperty(_curentAction)){
				_curentFrame++;
				
				if(_curentFrame >= _animDic[_curentAction].length){
					_curentFrame = 0;
					playOver();
				}
			}
		}
		public function perFrame():void{
			if(_curentAction && _animDic.hasOwnProperty(_curentAction)){
				_curentFrame--;
				
				if(_curentFrame < 0){
					_curentFrame = _animDic[_curentAction].length-1;
				}
			}
		}

		public function get pause():Boolean
		{
			return _pause;
		}

		public function set pause(value:Boolean):void
		{
			_pause = value;
		}
		
		public function clearData():void{
			trace("clear");
			_animDic = new Object;
			_textureDic = new Object;
			_meshDic = new Object;
			/*for(var key:String in _animDic){
				delete _animDic[key];
			}
			for(key in _textureDic){
				delete _textureDic[key];
			}
			for(key in _meshDic){
				delete _meshDic[key];
			}*/
			
		}

		
	}
}